<template>
  <li class="food-item">
    <div class="food-left">
      <img :src="img" alt="食品">
      <div class="food-left-info">
        <h3>{{ name }}</h3>
        <p>{{ description }}</p>
        <p>价格：{{ price }}元</p>
      </div>
    </div>
    <div class="food-right">
      <div @click="decrement">
        <i class="fa fa-minus-circle"></i>
      </div>
      <p><span>{{ count }}</span></p>
      <div @click="increment">
        <i class="fa fa-plus-circle"></i>
      </div>
    </div>
  </li>
</template>

<script>
export default {
  props: {
    img: {
      type: String,
      required: true
    },
    name: {
      type: String,
      required: true
    },
    price: {
      type: Number,
      required: true
    },
    description: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      count: 3 // 示例数量，可根据需求调整
    }
  },
  methods: {
    increment() {
      this.count++
    },
    decrement() {
      if (this.count > 0) {
        this.count--
      }
    }
  }
}
</script>

<style scoped>
.food-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2.5vw;
  border-bottom: 1px solid #eee;
}

.food-left {
  display: flex;
  align-items: center;
}

.food-left img {
  width: 20vw;
  height: 20vw;
  border-radius: 4px;
  object-fit: cover;
}

.food-left-info {
  margin-left: 3vw;
}

.food-left-info h3 {
  font-size: 3.8vw;
  margin: 0;
}

.food-left-info p {
  font-size: 3vw;
  color: #888;
  margin-top: 1vw;
  margin-bottom: 0;
}

.food-right {
  display: flex;
  align-items: center;
}

.food-right i {
  font-size: 5.5vw;
  cursor: pointer;
  color: #0097EF;
}

.food-right p {
  font-size: 3.6vw;
  margin: 0 2vw;
}
</style>